package com.ysyx.ysyx_ordersetstatu.controller;

import com.ysyx.ysyx_ordersetstatu.dto.BaseDto;
import com.ysyx.ysyx_ordersetstatu.qo.DriverCancelQo;
import com.ysyx.ysyx_ordersetstatu.qo.EndorderQo;
import com.ysyx.ysyx_ordersetstatu.qo.PassengerCancelQo;
import com.ysyx.ysyx_ordersetstatu.qo.SuretelQo;
import com.ysyx.ysyx_ordersetstatu.service.OrderPojoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by IntelliJ IDEA.
 *
 * @description: xxxx接口/类
 * @author:郭宇轩
 * @create:2023/4/12 11:49
 */
@RestController
@RequestMapping("/order")
public class OrderStatuController {


    @Autowired
    private OrderPojoService orderPojoService;

    /*
     * @Description: (作用)司机到达订单起点，通过手机后四位确认乘客
     * @params:Integer driverId;
               String orderId;
               String lastFourNum;
     * @return:101手机后四位匹配成功，订单开始行程
     *         201手机四位匹配失败
     *         301手机长度不足四位
     * @Author: 郭宇轩
     * @create:2023/4/12
     */
    @RequestMapping("/driver/suretel")
    public BaseDto suretel(SuretelQo suretelQo){

        BaseDto baseDto = orderPojoService.suretel(suretelQo);
        System.out.println("suretelQo = " + suretelQo);
        return baseDto;
    }
    /*
     * @Description: (作用)司机到达目的地 结束订单
     * @params: EndorderQo{String orderId 订单id;
                           Integer driverId 司机id;}
     * @return: BaseDto{
     *              private int statusCode 101;
     *              private String message "订单已结束";
     *              private List<?> list;
     *              }
     * @Author: 郭宇轩
     * @create:2023/4/12
     */
    @RequestMapping("/driver/endorder")
    public BaseDto endorder(EndorderQo endorderQo){

        BaseDto baseDto = orderPojoService.endorder(endorderQo);
        return baseDto;
    }

    /*
     * @Description: (作用)司机取消订单
     * @params:Integer driverId;
               String orderId;
               Double driverLongitude;
               Double driverLatitude;
     * @return:100(无意义),driverCancelQo.toString()(无意义)
     * @Author: 郭宇轩
     * @create:2023/4/14
     */
    @RequestMapping(value = "/driver/cancel",method = RequestMethod.POST)
    public BaseDto driverCancel(@RequestBody DriverCancelQo driverCancelQo){
        System.out.println("司机取消订单成功");
        BaseDto baseDto = orderPojoService.driverCancel(driverCancelQo);
        return baseDto;
    }

    /*
     * @Description: (作用)乘客取消订单(内部有判断没有分配司机,有分配司机)
     * @params:  Integer passengerId;
                 String orderId;
     * @return: 100(无意义),passengerCancelQo.toString()(无意义)
     * @Author: 郭宇轩
     * @create:2023/4/14
     */
    @RequestMapping(value = "/passenger/cancel",method = RequestMethod.POST)
    public BaseDto passengerCancel(@RequestBody PassengerCancelQo passengerCancelQo){
        System.out.println("乘客取消订单成功");
        BaseDto baseDto = orderPojoService.passengerCancel(passengerCancelQo);
        return baseDto;
    }






}
